package main

import "strings"

type CustomError struct {
	Message string `json:"message"`
	Err     error  `json:"err"`
}

func (ce *CustomError) Error() string {
	var errs []string
	errs = append(errs, ce.Message)
	if ce.Err != nil {
		errs = append(errs, ce.Err.Error())
	}
	return strings.Join(errs, ",")
}

func NewCustomError(m string, e error) *CustomError {
	return &CustomError{
		Message: m,
		Err:     e,
	}
}
